Expose aggregated metrics#204
Merged
flora-hofmann-frequenz merged 1 commit intofrequenz-floss:v0.x.xfrom Jul 9, 2025
Merged
Conversation
Signed-off-by: Flora <flora.hofmann@frequenz.com>
There was a problem hiding this comment.
Pull Request Overview
Updates the metric sample iterator to also expose aggregated metrics and documents this new capability.
- Adds handling for
aggregated_metric(avg, min, max, raw values) in__iter__. - Removes the old
math.nanfallback for missing simple metrics. - Updates release notes to mention the new feature.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/frequenz/client/reporting/_types.py | Expanded __iter__ to support aggregated_metric variants and dropped the NaN fallback. |
| RELEASE_NOTES.md | Added a bullet noting that aggregated metrics are now exposed. |
Comments suppressed due to low confidence (3)
src/frequenz/client/reporting/_types.py:104
- Add unit tests covering the new aggregated metric logic (avg, min, max, raw values) to verify correct iteration behavior and catch future regressions.
if sample.value.HasField("aggregated_metric"):
RELEASE_NOTES.md:13
- [nitpick] For consistency with the surrounding list style, replace the leading
*with-in this bullet point.
* Expose aggregated metrics if available.
src/frequenz/client/reporting/_types.py:104
- [nitpick] Use
elifinstead of a secondifwhen checking foraggregated_metricto ensure exclusive handling and avoid evaluating both branches if both fields were ever present.
if sample.value.HasField("aggregated_metric"):
cwasicki
approved these changes
Jul 9, 2025
This was referenced Jul 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Example:MetricSample(timestamp=datetime.datetime(2025, 7, 8, 9, 10, 20, tzinfo=datetime.timezone.utc), microgrid_id=13, component_id=262, metric='BATTERY_SOC_PCT_avg', value=43.198001861572266),
MetricSample(timestamp=datetime.datetime(2025, 7, 8, 9, 10, 20, tzinfo=datetime.timezone.utc), microgrid_id=13, component_id=262, metric='BATTERY_SOC_PCT_min', value=42.70000076293945),
MetricSample(timestamp=datetime.datetime(2025, 7, 8, 9, 10, 20, tzinfo=datetime.timezone.utc), microgrid_id=13, component_id=262, metric='BATTERY_SOC_PCT_max', value=43.29999923706055),